home *** CD-ROM | disk | FTP | other *** search
/ Chip: 2001 Haziran / CHIP Haziran2001.iso / prog / share / 04 / setup.exe / MM27.Cab / F856_JSA.h.0162E57D_7C98_4D94_A1CA_6231808F03E6 < prev    next >
Text File  |  2000-09-14  |  5KB  |  153 lines

  1. /*************************************************************************
  2. *
  3. * ADOBE CONFIDENTIAL
  4. * ___________________
  5. *
  6. *  Copyright 2000 Adobe Systems Incorporated
  7. *  All Rights Reserved.
  8. *
  9. * NOTICE:  All information contained herein is, and remains the property of 
  10. * Adobe Systems Incorporated  and its suppliers, if any.  The  intellectual 
  11. * and technical concepts contained herein are proprietary to  Adobe Systems 
  12. * Incorporated a nd its suppliers  and may be covered by U. S. and  Foreign 
  13. * Patents,patents in process,and are protected by trade secret or copyright 
  14. * law.  Dissemination of this information or reproduction  of this material
  15. * is strictly forbidden  unless prior  written permission  is obtained from 
  16. * Adobe Systems Incorporated.
  17. *
  18. **************************************************************************/
  19.  
  20. // ----------------------------------------------------------------
  21. // JSA++.h
  22. // Definitions for the GoLive Extend Script SDK
  23. // ----------------------------------------------------------------
  24.  
  25. #ifndef _JSAPP_H_
  26. #define _JSAPP_H_
  27.  
  28. /* The JSA Javascript Interface
  29.  
  30. This interface needs the include files for the ExtendScript interpreter. As opposed to the plain
  31. C interface, full access to the values and the runtime engine is provided. The ExtendScript headers
  32. can be found in an update to the SDK. To receive the latest version of the Extend Script SDK, 
  33. please check the GoLive pages on www.adobe.com.
  34.  
  35. The JSA interface permits developers to write binary code extensions for the Extend Script SDK.
  36. All modules must reside in the Extend Script subdirectory Common, and all functions are callable by all
  37. Javascript extension modules. The functions are accessible as parts of a Javscript object
  38. which has the same name as the DLL or SharedLib. If, for example, the DLL is called "SomeExt.DLL",
  39. and it contains a function "foo", the function is callable as "SomeExt.foo()".
  40.  
  41. See the documentation for further information.
  42.  
  43. When writing a module, it is important to implement the macro JSA_INIT once which defines some data
  44. structures and perfoms the necessary initialization of the module.
  45. */
  46.  
  47. /// This header file needs the ExtendScript headers.
  48.  
  49. #include "ExtendScript.h"
  50.  
  51. extern "C" {
  52.  
  53. #ifdef WIN32
  54. #define JSAEXPORT __declspec(dllexport)
  55. #else
  56. #define JSAEXPORT
  57. #endif
  58.  
  59. struct JSAEnv;
  60.  
  61. /**
  62. The JSAMain function is called from within the JSA_INIT macro. It should be used
  63. to register all functions callable by the Extend Script SDK. It is called when the
  64. module has been loaded, which the SDK does on demand before calling the first
  65. function inside the module.
  66. */
  67. extern    void JSAEXPORT JSAMain(void);
  68.  
  69. /**
  70. The JSAExit function is called when the extension module is about to be unloaded.
  71. Here, the module may be deinitialized.
  72. */
  73. extern    void JSAEXPORT JSAExit(void);
  74.  
  75. /**
  76. All callable functions must be encoded as JSANativeMethods. They receive
  77. an argc/argv combination as well as a location to store the return value.
  78. @param    argc    the number of arguments
  79. @param    argv    the argument vector as pointer to sValue instances
  80. @param    retval    a location to store any return value, preset to undefined
  81. */
  82. typedef void (*JSANativeMethod)(int argc, const sValue* argv[], sValue* returnValue);
  83.  
  84. /**
  85. Register a function by name within the Javascript extension. Only registered functions can
  86. be called from within the Javascirpt extension modules. The function must be a JSANativeMethod.
  87. The location to register functions is within the JSAMain() function.
  88. @param    n            the function name. The name must follow Javascript naimg conventions.
  89. @param    f            the function itself (a JSANativeMethod)
  90. */
  91. #define JSARegisterFunction(n,f)    JSAEnvObj->regFct(JSAEnvObj,n,f)
  92.  
  93. /**
  94. Retrieve a pointer to the currently running engine. This engine may belong to any active module.
  95. It is, however, the engine which called the current function.
  96. @return                a pointer to the current engine.
  97. */
  98. #define    JSAGetEngine()                (sEngine*) JSAEnvObj->jsaInst
  99.  
  100. /**
  101. The structure supplied to allow for drawing inside a module.
  102. The Draw.getDrawInfo() method of the Extend Script SDK returns a long value which is really a
  103. pointer to a JSADrawInfo structure. The pointer may be retrieved by JSAValueToInt() and casted
  104. to a JSADrawInfo structure. The contents of the structure can be used to implement drawing
  105. in native code.
  106. */
  107. struct JSADrawInfo
  108. {
  109.     /// The device context. This is a DC handle on Windows or a GrafPtr pointer on the Mac.
  110.     long        context;
  111.     /// The top left corner of the current drawing area.
  112.     long        left, top;
  113.     /// The bottom right corner of the current drawing area.
  114.     long        right, bottom;
  115. };
  116.  
  117. // ////////////////////////////////////////////////////////////////////////////
  118.  
  119. typedef void (*JSARegisterFunctionFct)(JSAEnv *, const char *name, JSANativeMethod);
  120.  
  121. struct JSAEnv
  122. {
  123.     long                    jsaStructSize;
  124.     long                    jsaVersion;
  125.     void *                    jsaInst;
  126.     void *                    externalRef;
  127.     void *                    internal[9];
  128.     JSARegisterFunctionFct    regFct;
  129. };
  130.  
  131. // ---------- Implementation ----------------
  132.  
  133. extern    JSAEnv    *JSAEnvObj;
  134. extern    void JSAEXPORT JSAEntry(JSAEnv *env);
  135.  
  136. #define JSA_INIT            \
  137.                             \
  138. JSAEnv    *JSAEnvObj;            \
  139.                             \
  140. void main()                    \
  141. {                            \
  142. }                            \
  143.                             \
  144. void JSAEXPORT JSAEntry(JSAEnv *env)    \
  145. {                            \
  146.     JSAEnvObj = env;        \
  147.     JSAMain();                \
  148. }                            \
  149.  
  150. }
  151.  
  152. #endif
  153.